<%@ page language="java" contentType="text/html; charset=utf-8 " pageEncoding="utf-8" import="domain.Room,domain.Info,java.util.ArrayList"%>
<html>
	<head>
		<meta charset="utf-8">
		<base href="<%=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/" %>"/>
        <title>常住人员管理</title>
	</head>
	<script type = "text/javascript">
                	        function messageLoad(){
                                		var message = '<%=request.getAttribute("message") %>';
                                		if(message != 'null'){
                                			alert(message);
                                		}
                                	}
        	</script>
	<style type="text/css">
		body{padding:0px;margin:0px;}
		.bgdiv{
			background:url(image/background.png) no-repeat;
			position: fixed;
			width: 100%;
			height: 100%;
			background-size:100% 100%;
		}
		.menu{
			position: fixed;
			bottom: 0;
			width: 100%;
			height: 10%;
			background: white;
			box-shadow: rgba(0, 0, 0, 0.08) 2px 0px 0px 0px;
			border-top: 1px black solid;
		}
		.main{
			position: absolute;
			left: 5%;
			top: 5%;
			width: 90%;
			height: 83%;
			background:rgba(255, 255, 255, 1);
			opacity:0.7;

		}
		.title{
			width: 80%;
			margin: auto;
			margin-top: 3%;
			border-bottom: 1px #000000 solid;
			font-size: 12px;
		}
		.mange{
			width: 80%;
			margin: auto;
			font-size: 11px;
			margin-top: 3%;
			padding-bottom: 3%;
			border-bottom: 1px #eeeeee solid;
		}
		button{
			border-width: 0px;

    left: 0px;
    top: 0px;
    width: 25%;
    height: 25px;
    background: inherit;
    background-color: rgba(0, 207, 226, 1);
    border: none;
    border-radius: 5px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    font-size: 14px;
    color: #FFFFFF;
	margin: 4%;
		}
		.info{
			overflow:auto;
			position: fixed;
			top: 18%;
			left: 10%;
			width: 80%;
			height: 65%;
			background: white;
		}
		.text{
			width: 99%;
			font-size: 10px;
			padding-top: 3%;
			padding-bottom: 3% ;
			position: relative;
			text-align: left;
		}
		.text:hover{
			background: #199ED8;
			color: white;
		}
		#shadow{
			width: 100%;
			height: 90%;
			background: rgba(255,255,255,0.8);
			position: fixed;
			top: 0px;
			left: 0px;
			display: none;
		}
		.noState{
			width: 40%;
			height: 20%;
			left: 7%;
			top: 20%;
			position: relative;
			text-align: center;
			border-radius: 15px;
			padding: 50px;
			color: #555555;
			font-size: 12px;
		}
	</style>
	<%
                            	Room room=new Room();
                            	if(session.getAttribute("userloginflag")==null){
                            	%>
                            	<script type="text/javascript">
                            	    window.location.href="index.jsp";
                            	</script>
                                <% }else{
                                room=(Room)session.getAttribute("userloginflag");
                                %>
	<body onload="messageLoad()">
		<div class="bgdiv"></div>
			<div class="menu">
				<div style="position: absolute;left: 5%;width: 30%;height: 100%;" onclick="hrefPersion()">
					<center><span><img src="image/u37.png" height="35%" style="margin-top: 5%;" /></span><br />
					<span style="font-size: 70%;color: #199ED8;">常住</span></center>
				</div>
				<div style="position: absolute;left: 35%;width: 30%;height: 100%;" onclick="hrefVisitor()">
					<center><span><img src="image/u40.svg" height="35%" style="margin-top: 5%;" /></span><br />
					<span style="font-size: 70%;">访客</span></center>
				</div>
				<div style="position: absolute;right: 5%;width: 30%;height: 100%; " onclick="hrefMain()">
					<center><span><img src="image/u41.svg" height="35%" style="margin-top: 5%;" /></span><br />
					<span style="font-size: 70%;">我的</span></center>
				</div>
			</div>
			<div class="main">
				<button onclick="CreatNewPerson()" >新增</button><button id="updateInfo" onclick="update(this)" >查看</button><button id="delectInfo" onclick="delect(this)" style="background: #333333;">删除</button>
			</div>
		</div>
		<div class="info">
		<% ArrayList<Info> list = (ArrayList)request.getAttribute("list");
		    if(list.size()==0){
		    %>
			<div class="text"style="color: #555555;text-align: center;">暂无数据</div><% }
			for(int i=0;i<list.size();i++){ %>
			<div class="text" onclick="getInfoID(<%=list.get(i).getInfo_id() %>)"><span  style="margin-left: 10%;" ><%=list.get(i).getName() %></span><span  style="margin-left: 10%;"><%=list.get(i).getSex() %></span>
			<% if(list.get(i).getState()==0){ %>
			<span style="margin-left: 15%;color: #555555;">待审核</span>
			<% }if(list.get(i).getState()==1){ %>
			<span style="margin-left: 15%;color: green;">已审核</span>
			<% }if(list.get(i).getState()==2){ %>
            <span style="margin-left: 15%;color: red;">未通过</span><% }%>
			</div>
			<% } %>
		</div>
		<div id="shadow">
			<div class="noState">
				<img src="image/u46.svg" /><br />
				住房信息通过审核后才可使用
			</div>
		</div>
		<% if(room.getState()==0||room.getState()==2){
                                        %>
                                        <script type="text/javascript">
                                        document.getElementById("shadow").style.display="block";
                                        </script><% } %>
	</body><% } %>
	<script>
	    if(/Android (\d+\.\d+)/.test(navigator.userAgent)){
	       var version = parseFloat(RegExp.$1);
	    if(version>2.3){
	       var phoneScale = parseInt(window.screen.width)/230;
	       document.write('<meta name="viewport" content="width=230, minimum-scale = '+ phoneScale +', maximum-scale = '+ phoneScale +', user-scalable=no, target-densitydpi=device-dpi">');
	       }else{
	            document.write('<meta name="viewport" content="width=230, target-densitydpi=device-dpi">');
	       }
	       }else{
	            document.write('<meta name="viewport" content="width=230, user-scalable=no, target-densitydpi=device-dpi">');
	       }
		   function hrefPersion(){
			   window.location.href="PersonInfo";
		   }
		   function hrefVisitor(){
			   window.location.href="VisitorInfo";
		   }
		   function hrefMain(){
			   window.location.href="app/main.jsp";
		   }
			function getInfoID(e){
				document.getElementById("updateInfo").value=e;
				document.getElementById("delectInfo").value=e;
			}
			function update(e){
				if(e.value==""){
					alert('请选择一条数据');
				}else{
					window.location.href = "Person?info_id="+e.value;
				}
			}
			function delect(e){
			if(e.value==""){
					alert('请选择一条数据');
				}else{
					if(confirm("确定要删除吗？")){
					    window.location.href = "DelectPerson?info_id="+e.value;
					}
				}
			}
			function CreatNewPerson(){
			    window.location.href="app/person/CreatPerson.jsp";
			}
	</script>
</html>